package com.one.square.user.server.controller;

import com.one.square.core.domain.LoginAppUser;
import com.one.square.core.domain.Result;
import com.one.square.core.utils.JwtUtils;
import com.one.square.core.utils.RequestUtils;
import com.one.square.user.interfaces.service.service.SysUserInterface;
import com.one.square.user.server.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cwm
 * @Description 用户模块接口
 * @date 2021/10/21 上午11:31
 * @Version 1.0
 */
@RestController
@RequestMapping("/sys/user")
@AllArgsConstructor
@Api(value = "/sys/user", tags = {"用户模块接口"})
public class SysUserController implements SysUserInterface {
    private final SysUserService sysUserService;

    @GetMapping("/find/by/username")
    @Override
    @ApiOperation(value = "根据用户名查询用户对象")
    public Result<LoginAppUser> findByUsername(@RequestParam("username")
                                               @ApiParam(name = "username", value = "用户名", required = true)
                                                       String username) {
        return Result.succeed(sysUserService.findByUsername(username));
    }


    @GetMapping("/find/by/mobile")
    @Override
    @ApiOperation(value = "根据手机号码查询用户对象")
    public Result<LoginAppUser> findByMobile(@RequestParam("mobile")
                                             @ApiParam(name = "mobile", value = "手机号码", required = true)
                                                     String mobile) {
        return Result.succeed(sysUserService.findByUsername(mobile));
    }

}
